/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('xgippop', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model CreateApplicationRequest {
  aliUid?: long(name='AliUid', description='阿里UID'),
  appName?: string(name='AppName', description='应用名称'),
  appTypeList?: [ string ](name='AppTypeList', description='dynamic（动态业务）/static（静态业务'),
  appingList?: [ 
    {
      extId?: long(name='ExtId'),
      flowIp?: [ string ](name='FlowIp', description='cdn ip'),
      flowUrl?: [ string ](name='FlowUrl', description='cdn 域名信息'),
      originalIpList?: [ string ](name='OriginalIpList', description='业务方ip集合'),
      originalUrlList?: [ string ](name='OriginalUrlList', description='业务方域名集合'),
    }
  ](name='AppingList'),
  itemCode?: string(name='ItemCode', description='商品code'),
  requestId?: string(name='RequestId', description='请求幂等'),
  securityToken?: string(name='SecurityToken'),
  appIp?: string(name='app_ip'),
  callerParentId?: long(name='callerParentId'),
  callerType?: string(name='callerType'),
  callerUid?: long(name='callerUid'),
  resource?: string(name='resource'),
  stsParentAccount?: long(name='stsParentAccount', description='sts 主账号'),
  stsTokenCallerUid?: long(name='stsTokenCallerUid', description='sts 子账号'),
}

model CreateApplicationShrinkRequest {
  aliUid?: long(name='AliUid', description='阿里UID'),
  appName?: string(name='AppName', description='应用名称'),
  appTypeListShrink?: string(name='AppTypeList', description='dynamic（动态业务）/static（静态业务'),
  appingListShrink?: string(name='AppingList'),
  itemCode?: string(name='ItemCode', description='商品code'),
  requestId?: string(name='RequestId', description='请求幂等'),
  securityToken?: string(name='SecurityToken'),
  appIp?: string(name='app_ip'),
  callerParentId?: long(name='callerParentId'),
  callerType?: string(name='callerType'),
  callerUid?: long(name='callerUid'),
  resource?: string(name='resource'),
  stsParentAccount?: long(name='stsParentAccount', description='sts 主账号'),
  stsTokenCallerUid?: long(name='stsTokenCallerUid', description='sts 子账号'),
}

model CreateApplicationResponseBody = {
  appId?: string(name='AppId', description='应用id'),
  code?: string(name='Code', description='结果码'),
  message?: string(name='Message', description='结果描述'),
  requestId?: string(name='RequestId', description='请求ID'),
  success?: boolean(name='Success', description='是否成功'),
}

model CreateApplicationResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateApplicationResponseBody(name='body'),
}

async function createApplication(request: CreateApplicationRequest): CreateApplicationResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return createApplicationWithOptions(request, headers, runtime);
}

async function createApplicationWithOptions(tmpReq: CreateApplicationRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CreateApplicationResponse {
  Util.validateModel(tmpReq);
  var request = new CreateApplicationShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.appTypeList)) {
    request.appTypeListShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.appTypeList, 'AppTypeList', 'json');
  }
  if (!Util.isUnset(tmpReq.appingList)) {
    request.appingListShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.appingList, 'AppingList', 'json');
  }
  var body : map[string]any= {};
  if (!Util.isUnset(request.aliUid)) {
    body['AliUid'] = request.aliUid;
  }
  if (!Util.isUnset(request.appName)) {
    body['AppName'] = request.appName;
  }
  if (!Util.isUnset(request.appTypeListShrink)) {
    body['AppTypeList'] = request.appTypeListShrink;
  }
  if (!Util.isUnset(request.appingListShrink)) {
    body['AppingList'] = request.appingListShrink;
  }
  if (!Util.isUnset(request.itemCode)) {
    body['ItemCode'] = request.itemCode;
  }
  if (!Util.isUnset(request.requestId)) {
    body['RequestId'] = request.requestId;
  }
  if (!Util.isUnset(request.securityToken)) {
    body['SecurityToken'] = request.securityToken;
  }
  if (!Util.isUnset(request.appIp)) {
    body['app_ip'] = request.appIp;
  }
  if (!Util.isUnset(request.callerParentId)) {
    body['callerParentId'] = request.callerParentId;
  }
  if (!Util.isUnset(request.callerType)) {
    body['callerType'] = request.callerType;
  }
  if (!Util.isUnset(request.callerUid)) {
    body['callerUid'] = request.callerUid;
  }
  if (!Util.isUnset(request.resource)) {
    body['resource'] = request.resource;
  }
  if (!Util.isUnset(request.stsParentAccount)) {
    body['stsParentAccount'] = request.stsParentAccount;
  }
  if (!Util.isUnset(request.stsTokenCallerUid)) {
    body['stsTokenCallerUid'] = request.stsTokenCallerUid;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateApplication',
    version = '2022-03-18',
    protocol = 'HTTPS',
    pathname = `/freeflow/CreateApplication`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model GetApplicationRequest {
  aliUid?: long(name='AliUid', description='阿里UID'),
  appCode?: string(name='AppCode'),
  requestId?: string(name='RequestId', description='请求幂等'),
  resource?: string(name='Resource'),
  securityToken?: string(name='SecurityToken'),
  appId?: string(name='app_id'),
  callerParentId?: long(name='callerParentId'),
  callerType?: string(name='callerType'),
  callerUid?: long(name='callerUid'),
  stsAccount?: long(name='stsAccount', description='sts 子账号'),
  stsParentAccount?: long(name='stsParentAccount', description='sts 主账号'),
}

model GetApplicationResponseBody = {
  code?: string(name='Code', description='结果码'),
  data?: [ 
    {
      aliUid?: long(name='AliUid', description='用户编号'),
      appId?: string(name='AppId', description='应用编号'),
      appName?: string(name='AppName', description='应用名称'),
      appStatus?: string(name='AppStatus'),
      appTypeList?: string(name='AppTypeList', description='//dynamic（动态业务）/static（静态业务）  // 前端传递，参数3'),
      appingList?: [ 
        {
          extId?: long(name='ExtId'),
          flowIp?: [ string ](name='FlowIp', description='cdn ip'),
          flowUrl?: [ string ](name='FlowUrl', description='cdn 域名信息'),
          originalIpList?: [ string ](name='OriginalIpList', description='业务方ip集合'),
          originalUrlList?: [ string ](name='OriginalUrlList', description='业务方域名集合'),
        }
      ](name='AppingList'),
      endTime?: string(name='EndTime'),
      itemCode?: string(name='ItemCode', description='Database Column Remarks:'),
      openTime?: string(name='OpenTime', description='开通时间'),
      startTime?: string(name='StartTime'),
    }
  ](name='Data', description='结果'),
  message?: string(name='Message', description='结果描述'),
  requestId?: string(name='RequestId', description='请求链路ID，如POP请求进来的requestId，返回时原样返回'),
  rt?: long(name='Rt', description='服务端处理耗时，ms'),
  success?: boolean(name='Success', description='是否成功'),
}

model GetApplicationResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetApplicationResponseBody(name='body'),
}

async function getApplication(request: GetApplicationRequest): GetApplicationResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getApplicationWithOptions(request, headers, runtime);
}

async function getApplicationWithOptions(request: GetApplicationRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetApplicationResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.appCode)) {
    query['AppCode'] = request.appCode;
  }

  var body : map[string]any= {};
  if (!Util.isUnset(request.aliUid)) {
    body['AliUid'] = request.aliUid;
  }
  if (!Util.isUnset(request.requestId)) {
    body['RequestId'] = request.requestId;
  }
  if (!Util.isUnset(request.resource)) {
    body['Resource'] = request.resource;
  }
  if (!Util.isUnset(request.securityToken)) {
    body['SecurityToken'] = request.securityToken;
  }
  if (!Util.isUnset(request.appId)) {
    body['app_id'] = request.appId;
  }
  if (!Util.isUnset(request.callerParentId)) {
    body['callerParentId'] = request.callerParentId;
  }
  if (!Util.isUnset(request.callerType)) {
    body['callerType'] = request.callerType;
  }
  if (!Util.isUnset(request.callerUid)) {
    body['callerUid'] = request.callerUid;
  }
  if (!Util.isUnset(request.stsAccount)) {
    body['stsAccount'] = request.stsAccount;
  }
  if (!Util.isUnset(request.stsParentAccount)) {
    body['stsParentAccount'] = request.stsParentAccount;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GetApplication',
    version = '2022-03-18',
    protocol = 'HTTPS',
    pathname = `/freeflow/GetApplication`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model GetFreeFlowStatusRequest {
  appId?: string(name='AppId', description='应用ID'),
  flowProductId?: string(name='FlowProductId', description='免流产品ID'),
  mobileNumber?: string(name='MobileNumber', description='C端手机号'),
  netType?: string(name='NetType', description='网络类型，如3G、4G、5G'),
  operator?: string(name='Operator', description='取值包括cm（中国移动）/ct（中国电信）/cu（中国联通）'),
  privateIP?: string(name='PrivateIP', description='手机端私网ip地址'),
  pseudoCode?: string(name='PseudoCode', description='C端手机在运营商侧端伪码，如："75D35971BD"'),
  publicIP?: string(name='PublicIP', description='手机端公网ip地址'),
  requestId?: string(name='RequestId', description='请求幂等'),
  securityToken?: string(name='SecurityToken'),
  token?: string(name='Token', description='通过云通信获取的token'),
  appIp?: string(name='app_ip'),
  callerParentId?: long(name='callerParentId'),
  callerType?: string(name='callerType'),
  callerUid?: long(name='callerUid'),
  resource?: string(name='resource'),
  stsAccount?: long(name='stsAccount', description='sts 子账号'),
  stsParentAccount?: long(name='stsParentAccount', description='sts 主账号'),
}

model GetFreeFlowStatusResponseBody = {
  code?: string(name='Code', description='结果码'),
  data?: any(name='Data', description='结果'),
  message?: string(name='Message', description='结果描述'),
  requestId?: string(name='RequestId', description='请求链路ID，如POP请求进来的requestId，返回时原样返回'),
  rt?: long(name='Rt', description='服务端处理耗时，ms'),
  success?: boolean(name='Success', description='是否成功'),
}

model GetFreeFlowStatusResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetFreeFlowStatusResponseBody(name='body'),
}

async function getFreeFlowStatus(request: GetFreeFlowStatusRequest): GetFreeFlowStatusResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getFreeFlowStatusWithOptions(request, headers, runtime);
}

async function getFreeFlowStatusWithOptions(request: GetFreeFlowStatusRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetFreeFlowStatusResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.appId)) {
    body['AppId'] = request.appId;
  }
  if (!Util.isUnset(request.flowProductId)) {
    body['FlowProductId'] = request.flowProductId;
  }
  if (!Util.isUnset(request.mobileNumber)) {
    body['MobileNumber'] = request.mobileNumber;
  }
  if (!Util.isUnset(request.netType)) {
    body['NetType'] = request.netType;
  }
  if (!Util.isUnset(request.operator)) {
    body['Operator'] = request.operator;
  }
  if (!Util.isUnset(request.privateIP)) {
    body['PrivateIP'] = request.privateIP;
  }
  if (!Util.isUnset(request.pseudoCode)) {
    body['PseudoCode'] = request.pseudoCode;
  }
  if (!Util.isUnset(request.publicIP)) {
    body['PublicIP'] = request.publicIP;
  }
  if (!Util.isUnset(request.requestId)) {
    body['RequestId'] = request.requestId;
  }
  if (!Util.isUnset(request.securityToken)) {
    body['SecurityToken'] = request.securityToken;
  }
  if (!Util.isUnset(request.token)) {
    body['Token'] = request.token;
  }
  if (!Util.isUnset(request.appIp)) {
    body['app_ip'] = request.appIp;
  }
  if (!Util.isUnset(request.callerParentId)) {
    body['callerParentId'] = request.callerParentId;
  }
  if (!Util.isUnset(request.callerType)) {
    body['callerType'] = request.callerType;
  }
  if (!Util.isUnset(request.callerUid)) {
    body['callerUid'] = request.callerUid;
  }
  if (!Util.isUnset(request.resource)) {
    body['resource'] = request.resource;
  }
  if (!Util.isUnset(request.stsAccount)) {
    body['stsAccount'] = request.stsAccount;
  }
  if (!Util.isUnset(request.stsParentAccount)) {
    body['stsParentAccount'] = request.stsParentAccount;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GetFreeFlowStatus',
    version = '2022-03-18',
    protocol = 'HTTPS',
    pathname = `/freeflow/getFreeFlowStatus`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model ModifyApplicationRequest {
  appCode?: string(name='AppCode', description='AppId'),
  appName?: string(name='AppName', description='应用名称'),
  appTypeList?: [ string ](name='AppTypeList', description='dynamic（动态业务）/static（静态业务'),
  appingList?: [ 
    {
      extId?: long(name='ExtId'),
      flowIp?: [ string ](name='FlowIp', description='cdn ip'),
      flowUrl?: [ string ](name='FlowUrl', description='cdn 域名信息'),
      originalIpList?: [ string ](name='OriginalIpList', description='业务方ip集合'),
      originalUrlList?: [ string ](name='OriginalUrlList', description='业务方域名集合'),
    }
  ](name='AppingList', description='扩展属性 源域名和源ip信息保存'),
  requestId?: string(name='RequestId', description='请求幂等'),
  securityToken?: string(name='SecurityToken'),
  appIp?: string(name='app_ip'),
  callerParentId?: long(name='callerParentId'),
  callerType?: string(name='callerType'),
  callerUid?: long(name='callerUid'),
  resource?: string(name='resource'),
  stsParentAccount?: long(name='stsParentAccount', description='sts 主账号'),
  stsTokenCallerUid?: long(name='stsTokenCallerUid', description='sts 子账号'),
}

model ModifyApplicationShrinkRequest {
  appCode?: string(name='AppCode', description='AppId'),
  appName?: string(name='AppName', description='应用名称'),
  appTypeListShrink?: string(name='AppTypeList', description='dynamic（动态业务）/static（静态业务'),
  appingListShrink?: string(name='AppingList', description='扩展属性 源域名和源ip信息保存'),
  requestId?: string(name='RequestId', description='请求幂等'),
  securityToken?: string(name='SecurityToken'),
  appIp?: string(name='app_ip'),
  callerParentId?: long(name='callerParentId'),
  callerType?: string(name='callerType'),
  callerUid?: long(name='callerUid'),
  resource?: string(name='resource'),
  stsParentAccount?: long(name='stsParentAccount', description='sts 主账号'),
  stsTokenCallerUid?: long(name='stsTokenCallerUid', description='sts 子账号'),
}

model ModifyApplicationResponseBody = {
  appId?: string(name='AppId', description='应用id'),
  code?: string(name='Code', description='结果码'),
  message?: string(name='Message', description='结果描述'),
  requestId?: string(name='RequestId', description='请求ID'),
  success?: boolean(name='Success', description='是否成功'),
}

model ModifyApplicationResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ModifyApplicationResponseBody(name='body'),
}

async function modifyApplication(request: ModifyApplicationRequest): ModifyApplicationResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return modifyApplicationWithOptions(request, headers, runtime);
}

async function modifyApplicationWithOptions(tmpReq: ModifyApplicationRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ModifyApplicationResponse {
  Util.validateModel(tmpReq);
  var request = new ModifyApplicationShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.appTypeList)) {
    request.appTypeListShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.appTypeList, 'AppTypeList', 'json');
  }
  if (!Util.isUnset(tmpReq.appingList)) {
    request.appingListShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.appingList, 'AppingList', 'json');
  }
  var body : map[string]any= {};
  if (!Util.isUnset(request.appCode)) {
    body['AppCode'] = request.appCode;
  }
  if (!Util.isUnset(request.appName)) {
    body['AppName'] = request.appName;
  }
  if (!Util.isUnset(request.appTypeListShrink)) {
    body['AppTypeList'] = request.appTypeListShrink;
  }
  if (!Util.isUnset(request.appingListShrink)) {
    body['AppingList'] = request.appingListShrink;
  }
  if (!Util.isUnset(request.requestId)) {
    body['RequestId'] = request.requestId;
  }
  if (!Util.isUnset(request.securityToken)) {
    body['SecurityToken'] = request.securityToken;
  }
  if (!Util.isUnset(request.appIp)) {
    body['app_ip'] = request.appIp;
  }
  if (!Util.isUnset(request.callerParentId)) {
    body['callerParentId'] = request.callerParentId;
  }
  if (!Util.isUnset(request.callerType)) {
    body['callerType'] = request.callerType;
  }
  if (!Util.isUnset(request.callerUid)) {
    body['callerUid'] = request.callerUid;
  }
  if (!Util.isUnset(request.resource)) {
    body['resource'] = request.resource;
  }
  if (!Util.isUnset(request.stsParentAccount)) {
    body['stsParentAccount'] = request.stsParentAccount;
  }
  if (!Util.isUnset(request.stsTokenCallerUid)) {
    body['stsTokenCallerUid'] = request.stsTokenCallerUid;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ModifyApplication',
    version = '2022-03-18',
    protocol = 'HTTPS',
    pathname = `/freeflow/ModifyApplication`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model OrderQosServiceRequest {
  customerAccount?: string(name='CustomerAccount'),
  customerQosRequestId?: string(name='CustomerQosRequestId'),
  IPv6?: string(name='IPv6'),
  instanceId?: string(name='InstanceId'),
  privateIPv4?: string(name='PrivateIPv4'),
  publicIPv4?: string(name='PublicIPv4'),
  qosProductId?: string(name='QosProductId'),
  targetIp?: [ string ](name='TargetIp'),
  token?: string(name='Token'),
}

model OrderQosServiceResponseBody = {
  code?: int32(name='Code'),
  customerQosOrderId?: string(name='CustomerQosOrderId'),
  customerQosRequestId?: string(name='CustomerQosRequestId'),
  message?: string(name='Message'),
  requestId?: string(name='requestId', description='Id of the request'),
}

model OrderQosServiceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: OrderQosServiceResponseBody(name='body'),
}

async function orderQosService(request: OrderQosServiceRequest): OrderQosServiceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return orderQosServiceWithOptions(request, headers, runtime);
}

async function orderQosServiceWithOptions(request: OrderQosServiceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): OrderQosServiceResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.customerAccount)) {
    body['CustomerAccount'] = request.customerAccount;
  }
  if (!Util.isUnset(request.customerQosRequestId)) {
    body['CustomerQosRequestId'] = request.customerQosRequestId;
  }
  if (!Util.isUnset(request.IPv6)) {
    body['IPv6'] = request.IPv6;
  }
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.privateIPv4)) {
    body['PrivateIPv4'] = request.privateIPv4;
  }
  if (!Util.isUnset(request.publicIPv4)) {
    body['PublicIPv4'] = request.publicIPv4;
  }
  if (!Util.isUnset(request.qosProductId)) {
    body['QosProductId'] = request.qosProductId;
  }
  if (!Util.isUnset(request.targetIp)) {
    body['TargetIp'] = request.targetIp;
  }
  if (!Util.isUnset(request.token)) {
    body['Token'] = request.token;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'OrderQosService',
    version = '2022-03-18',
    protocol = 'HTTPS',
    pathname = `/qos/orderQosService`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

